<script>
export default {
  data(){
    return{
      alipayBean:{
        out_trade_no:"",
        subject:"",
        total_amount:""
      },
    }
  },
  created(){
    this.alipayBean.out_trade_no=this.$route.params.outTradeNo
    this.alipayBean.subject=this.$route.params.carName
    this.alipayBean.total_amount=this.$route.params.price
    console.log(this.$route.params.subject)
    console.log(this.$route.params.repaymentPrice)
    console.log(this.$route.params.outTradeNo)
  },
  methods:{
    weixin(){
      this.$router.push({name:"WxinPay",params:{outTradeNo:this.outTradeNo}})
    },
    zhifubao(){
      console.log("支付宝支付");
      this.axios.post('repay/repay/pay',this.alipayBean).then(res=>{
        const divForm = document.getElementsByTagName("div");
        if (divForm.length) {
          document.body.removeChild(divForm[0]);
        }
        const div = document.createElement("div");
        console.log(res.data.data.msg)
        div.innerHTML = res.data.data.msg; // data就是接口返回的form 表单字符串
        document.body.appendChild(div);
        document.forms[0].setAttribute("target", "_blank"); // 新开窗口跳转
        document.forms[0].submit();
      })
    }
  }
}
</script>

<template>
  <div id="pay">

    <el-form ref="form" :model="form" label-width="120px">
      <table>
        <el-form-item label="贷款商品名称">
          <el-input v-model="alipayBean.subject" style="width: 160px" disabled></el-input>
        </el-form-item>
        <el-form-item label="应还金额">
          <el-input v-model="alipayBean.total_amount" style="width: 160px" disabled></el-input>
        </el-form-item>
        <el-form-item label="订单编号">
          <el-input v-model="alipayBean.out_trade_no" style="width: 160px" disabled></el-input>
        </el-form-item>
<!--        <el-form-item>-->
<!--          <el-button type="primary" @click="onSubmit">提交订单</el-button>-->
<!--          <el-button>取消</el-button>-->
<!--        </el-form-item>-->
<!--        <el-button type="primary" @click="weixin">微信支付</el-button>-->
        <el-button type="primary" @click="zhifubao">支付宝支付</el-button>
      </table>
    </el-form>


  </div>

</template>

<style>

</style>
